package com.ruoyi.web.controller.littleRedBook;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.littleRedBook.domain.pojo.Reservation;
import com.ruoyi.littleRedBook.service.ReservationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.mail.Message;
import javax.mail.internet.InternetAddress;


/**
 * <p>
 * 预约表 前端控制器
 * </p>
 *
 * @author
 * @since 2025-09-10
 */
@RestController
@RequestMapping("/api/reservation")
public class ReservationController {

    @Autowired
    private ReservationService reservationService;

    /**
     * 新增预约
     */
    @PostMapping
    public AjaxResult add(@RequestBody Reservation reservation) {
        //TODO 后续需要进行预约后发送邮箱

        return AjaxResult.success(reservationService.save(reservation));
    }

//    /**
//     * 修改预约
//     */
//    @PutMapping
//    public AjaxResult edit(@RequestBody Reservation reservation) {
//        return AjaxResult.success(reservationService.updateById(reservation));
//    }
//
//    /**
//     * 删除预约
//     */
//    @DeleteMapping("/{reservationIds}")
//    public AjaxResult remove(@PathVariable Long[] reservationIds) {
//        return AjaxResult.success(reservationService.removeByIds(Arrays.asList(reservationIds)));
//    }

    /**
     * 查询预约详情
     */
    @GetMapping("/{reservationId}")
    public AjaxResult getInfo(@PathVariable Long reservationId) {
        return AjaxResult.success(reservationService.getById(reservationId));
    }

    /**
     * 查询预约列表
     */
    @GetMapping
    public AjaxResult list() {
        return AjaxResult.success(reservationService.list());
    }
}
